﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using QuanLyBus.Model;

namespace QuanLyBus
{
    public partial class Them_tuyen : PhoneApplicationPage
    {
        QL_TuyenDataContext db = new QL_TuyenDataContext(App.constr);
        public Them_tuyen()
        {
            InitializeComponent();
        }

        private void btn_cancel_Click(object sender, EventArgs e)
        {
            this.NavigationService.GoBack();
        }
        protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
        {
            this.NavigationService.GoBack();
            base.OnBackKeyPress(e);
        }

        private void btn_add_Click(object sender, EventArgs e)
        {
            int id_tuyen_txt;
            string ten_tuyen_di_txt,ten_tuyen_den_txt;
            id_tuyen_txt= int.Parse(txt_id_tuyen.Text);
            ten_tuyen_den_txt = txt_ten_tuyen_den.Text;
            ten_tuyen_di_txt = txt_ten_tuyen_di.Text;
            db.ds_tuyens.InsertOnSubmit(new ds_tuyen() {id_tuyen=id_tuyen_txt,ten_tuyen_den=ten_tuyen_den_txt,ten_tuyen_di=ten_tuyen_di_txt });
            db.SubmitChanges();
            MessageBox.Show("Thêm Thành Công");
            this.NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
            
        }
    }
}